# 导包
import jsonschema
# 准备被测数据  json  列表 + 字典
data = {
    "success": True,
    "code": 10000,
    "message": "操作成功",
    "data": {
        "name": "tom",
        "age": 18
    }
}
# data = "阿泰你个老六,不讲武德"
# 编写schema
schema = {
    "type": "object",
    "properties": {
        "success": {"type": "boolean"},
        "code": {"type": "integer"},
        "message": {"type": "string"},
        "data": {
            "type":"object",
            "properties": {
                "name": {"type": "string"},
                "age": {"type": "integer"}
            }
        }
}}
# schema = {
#     "type":"string"
# }
# 调用validate方法检查数据
result = jsonschema.validate(instance=data, schema=schema)

print(result)